[% setvar title pack/unpack C-like enhancements %]
<div id="archive-notice">
    <h3>This file is part of the Perl 6 Archive</h3>
    <p>To see what is currently happening visit <a href="http://www.perl6.org/">http://www.perl6.org/</a></p>
</div>
<div class='pod'>
<a name='TITLE'></a><h1>TITLE</h1>
<p>pack/unpack C-like enhancements</p>
<a name='VERSION'></a><h1>VERSION</h1>
<pre>  Maintainer: Ilya Zakharevich &lt;<a href='mailto:ilya@math.ohio-state.edu'>ilya@math.ohio-state.edu</a>&gt;
  Date: 16 September 2000
  Mailing List: <a href='mailto:perl6-language-data@perl.org'>perl6-language-data@perl.org</a>
  Number: 247
  Version: 1
  Status: Developing</pre>
<a name='ABSTRACT'></a><h1>ABSTRACT</h1>
<p>This RFC proposes C-like syntactic sugar to templates of pack/unpack.</p>
<a name='DESCRIPTION'></a><h1>DESCRIPTION</h1>
<p>An alternative style of type specifiers is allowed in pack()/unpack()
TEMPLATEs.  This style is used in the parts of the TEMPLATE enclosed
in braces, as in <code>'{ C_STYLE_TEMPLATE }'</code>.  Optionally, if TEMPLATE
starts with <code>'struct {'</code> (with possible intervening whitespace and comments)
<code>struct</code> is ignored.</p>
<p>When this style is in scope, then</p>
<ul>
<li><a name='the counts of the form 32 are prohibited, use [32] instead;'></a>the counts of the form <code>32</code> are prohibited, use <code>[32]</code> instead;</li>
<li><a name='struct {TEMPLATE} should be used instead of (TEMPLATE) for grouping;'></a><code>struct {TEMPLATE}</code> should be used instead of <code>(TEMPLATE)</code> for grouping;</li>
<li><a name='instead of one-char type specifiers, the corresponding C-like specifiers int/char/short/long/long long should be used. They may be preceeded by unsigned/signed/native/little-endian/big-endian, (native being the default). The type string should be used instead of a, with modifiers byte/utf8 if needed.'></a>instead of one-char type specifiers, the corresponding C-like specifiers
<code>int</code>/<code>char</code>/<code>short</code>/<code>long</code>/<code>long long</code> should be used.  They may be
preceeded by <code>unsigned</code>/<code>signed</code>/<code>native</code>/<code>little-endian</code>/<code>big-endian</code>,
(<code>native</code> being the default).  The type <code>string</code> should be used instead
of <code>a</code>, with modifiers <code>byte</code>/<code>utf8</code> if needed.</li>
<p><code>ignore</code> may be used to replace <code>'x'</code>. <code>aligh(LEN)</code> may be used as a
prefix to replace <code>'x!LEN'</code>;</p>
<li><a name='I8/I16/I32/U8/U16/U32 can be used too;'></a><code>I8</code>/<code>I16</code>/<code>I32</code>/<code>U8</code>/<code>U16</code>/<code>U32</code> can be used too;</li>
<li><a name='C9X syntax int_8 (sp?) etc. can be used too;'></a>C9X syntax <code>int_8</code> (sp?) etc. can be used too;</li>
<li><a name='[] should be used instead of *, as in '{ int[4]; short[] }';'></a><code>[]</code> should be used instead of <code>*</code>, as in <code>'{ int[4]; short[] }'</code>;</li>
<li><a name='if a type is put inside [], it should start with sizeof, as in '{ string[ sizeof long ] }' which is equivalent to a[L].'></a>if a type is put inside <code>[]</code>, it should start with <code>sizeof</code>, as
in <code>'{ string[ sizeof long ] }'</code> which is equivalent to <code>a[L]</code>.</li>
</ul>
<a name='MIGRATION ISSUES'></a><h1>MIGRATION ISSUES</h1>
<p>None.</p>
<a name='IMPLEMENTATION'></a><h1>IMPLEMENTATION</h1>
<p>Straightforward.</p>
<a name='REFERENCES'></a><h1>REFERENCES</h1>
<p>RFC 142: Enhanced Pack/Unpack</p>
<p>RFC 246: pack/unpack uncontrovercial enhancements</p>
</div>
